package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IHomepageService;
import com.mall.shopping.dto.HomepageResponse;
import com.mall.user.annotation.Anoymous;
import com.mall.user.constants.SysRetCodeConstants;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname HomepageController
 * @Description /shopping/homepage
 * @Date 2021/5/23 22:18
 * @Created by virus
 */
@RestController
@RequestMapping("shopping")
@Anoymous
public class HomepageController {

    @Reference(check = false)
    private IHomepageService iHomepageService;

    @RequestMapping("homepage")
    public ResponseData homepage() {

        HomepageResponse response = iHomepageService.homepage();
        if (response.getCode().equals(SysRetCodeConstants.SUCCESS.getCode())) {
            return new ResponseUtil<>().setData(response.getPanelContentItemDtos());
        }
        return new ResponseUtil<>().setErrorMsg(response.getMsg());
    }

}
